package com.serverTechnology.craft.controller;


import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import com.serverTechnology.craft.entity.dto.StandardParameterDto;
import com.serverTechnology.craft.entity.dto.StepsParameterInsertDto;
import com.serverTechnology.craft.entity.vo.StepsParameterVo;
import com.serverTechnology.craft.service.StepsParameterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工步所需要的参数 前端控制器
 *
 * @author 王烁
 * @since 2024-08-01
 */
@RestController
@Api(tags = "工艺参数管理")
@RequestMapping("/stepsParameter")
public class StepsParameterController {
    @Autowired
    private StepsParameterService stepsParameterService;

    @ApiOperation("获取是否非标设备、工装、工具")
    @PostMapping("/getStepsParameter")
    public ResponseData<List<StepsParameterVo>> getStandardParameter(@RequestBody StandardParameterDto standardParameterDto) {
        List<StepsParameterVo> stepsParameter = stepsParameterService.getStepsParameter(standardParameterDto);
        return new SuccessResponseData<>(stepsParameter);
    }

    @ApiOperation("添加所需标准、非标设备、工装、工具")
    @PostMapping("/insertStepsParameter")
    public ResponseData insertStepsParameter(@RequestBody StepsParameterInsertDto stepsParameter) {
        stepsParameterService.insertStepsParameter(stepsParameter);
        return new SuccessResponseData<>();
    }

    @ApiOperation("删除所需标准、非标设备、工装、工具")
    @PostMapping("/deleteStepsParameter")
    public ResponseData deleteStepsParameter(@RequestBody Long id) {
        stepsParameterService.deleteStepsParameter(id);
        return new SuccessResponseData<>();
    }

    @ApiOperation("修改所需标准、非标设备、工装、工具")
    @PostMapping("/updateStepsParameter")
    public ResponseData updateStepsParameter(@RequestBody List<StepsParameterInsertDto> stepsParameter) {
        stepsParameterService.updateStepsParameter(stepsParameter);
        return new SuccessResponseData<>();
    }

}
